package cn.hdu.liang.concurrency;


import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class Exam6 implements Runnable {
    @Override
    public void run() {
        Random random = new Random(System.currentTimeMillis());
        try {
            int i = random.nextInt(10) + 1;
            TimeUnit.SECONDS.sleep(i);
            System.out.println(i);
        } catch(InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        ExecutorService exec = Executors.newCachedThreadPool();
        for(int i = 0; i < 10; i++) {
            exec.execute(new Exam6());
        }
        exec.shutdown();
    }
}
